package com.iceland.client.client;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;

public abstract class Client {



    protected Bootstrap bs;
    protected EventLoopGroup workerGroup;

    public Client(int workThreadCount,Class channelClass){
        workerGroup=new NioEventLoopGroup(workThreadCount);
        bs=new Bootstrap();
        bs.group( workerGroup).channel(channelClass);
        preStart(bs);
    }

    protected abstract void preStart(Bootstrap bs);

    protected abstract void afterStart();
    
    public void close(){
        if(workerGroup!=null){
            workerGroup.shutdownGracefully();
        }
    }
}
